<template>
  <div class="animated fadeIn">
    <!-- 招标公告 2018/3/6 16:29 zhangQ -->
    <Row>
      <i-col :span="8">
        <Button type="primary" size="large" @click="addBidding">
          <Icon type="ios-download-outline"></Icon>
          添加招标公告
        </Button>
      </i-col>
    </Row>
    <Row>
      <i-col :md="24">
        <div>
          <div style="position:relative; margin-top: 20px;">
            <Table :columns="columns7" :data="main_order_list" ref="table" border></Table>
            <div style="position:absolute;top:0px;width:100%;height:100%;display: flex;
                                      align-items: center;
                                      justify-content: center;background: rgba(210, 216, 222, 0.5);"
                 v-if="list_loadding">
              <Spin size="large"></Spin>
              <h6 style="color:#2d8cf0;margin-top:10px;">正在获取数据...</h6>
            </div>
          </div>
          <Page :total="this.pageTotal" show-total @on-change="setInitPage"
                style="text-align:right;margin-top:50px" show-elevator></Page>
        </div>
      </i-col>
      <i-col :md="12">
      </i-col>
    </Row>
  </div>
</template>
<script>
  import { getProductDemandList, getBiddingList, deleteAnnouncement } from '@api/backEnd/productDemand'

  export default {
    name: 'billingList',
    data () {
      return {
        progresshow: false,
        progresscount: 0,
        progresstatus: 'active',
        progressspeed: 0,
        video_list: [],
        pageindex: 1,
        pageTotal: null,
        main_order_list: [],
        detailData: [],
        lodding: false,
        list_loadding: false,
        columns7: [
          {
            title: '项目名称',
            key: 'projectName'
          },
          {
            title: '公告区域',
            key: 'bulletinArea'
          },
          {
            title: '招标截止时间',
            ellipsis: 'false',
            key: 'endTime'
          },
          {
            title: '发布单位',
            ellipsis: 'false',
            key: 'publicCompany'
          },
          {
            title: '联系人',
            ellipsis: 'false',
            key: 'people'
          },
          {
            title: '联系电话',
            ellipsis: 'false',
            key: 'telephone'
          },
          {
            title: '联系邮箱',
            ellipsis: 'false',
            key: 'email'
          },
          {
            title: '操作',
            key: 'action',
            align: 'center',
            render: (h, params) => {
              return h('div', [
                h('Button', {
                  props: {
                    type: 'primary',
                    size: 'small'
                  },
                  style: {
                    marginRight: '5px'
                  },
                  on: {
                    click: () => {
                      console.log(params.row.id)
                      this.$router.push({ path: 'billing_edit/' + params.row.id })
                    }
                  }
                }, '编辑'),
                h('Button', {
                  props: {
                    type: 'error',
                    size: 'small'
                  },
                  on: {
                    click: () => {
                      this.$Modal.confirm({
                        content: '确定删除？',
                        onOk: () => {
                          let id = params.row.id
                          let that = this
                          deleteAnnouncement(id).then(res => {
                            if (+res.data.isSuccess === 1) {
                              that.$Message.info('删除成功')
                              that.setInitPage(1)
                            } else {
                              that.$Message.error('删除失败，' + res.data.res)
                            }
                          })
                        }
                      })
                    }
                  }
                }, '删除')
              ])
            }
          }
        ]
      }
    },
    computed: {},
    methods: {
      addBidding () {
        this.$router.push({ path: 'billing_add' })
      },
      handleSearch () {
        getProductDemandList().then(res => {
          console.log(this.searchForm + ' --- searchForm')
          if (res.data.isSuccess === 1) {
            this.main_order_list = res.data.data.list
          }
        })
      },
      remove (index) {
        this.video_list.splice(index, 1)
      },
      //      qiniu_upload () {
      //        uploader.start();
      //      },
      setInitPage (page) {
        this.pageindex = page
        let isMine = 1
        let type = 'all'
        const param = { page, isMine, type }
        getBiddingList(param).then(res => {
          if (res.data.isSuccess === 1) {
            console.log(res.data.data)
            this.main_order_list = res.data.data.list.reverse()
            this.pageTotal = res.data.data.total
          } else {
            this.main_order_list = []
            this.pageTotal = 0
          }
        })
      }
    },
    mounted () {
      const vue = this
      this.list_loadding = true
      setTimeout(function () {
        vue.list_loadding = false
      }, 2000)
      this.setInitPage(1)
    },
    components: {}
  }
</script>
<style scoped>

</style>
